/**
 * Created by LC on 2019/11/16
 */
package com.hw.paltfrom.controller.casemain;

import com.hw.paltfrom.service.casemain.SourceEnterpriseService;
import com.hw.paltfrom.vo.SourceVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Map;

/**
 *
 * 源头企业接口
 */
@RestController
@RequestMapping("source")
public class SourceEnterpriseController {

    @Autowired
    SourceEnterpriseService sourceEnterpriseService;

    //过滤空Date数据
    @InitBinder
    protected void initBinder(WebDataBinder binder) {
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true));
    }

    /**
     * 查询
     * @return
     */
    @RequestMapping("query")
    public Map<String,Object> queryList(@RequestBody SourceVo vo){
        return sourceEnterpriseService.queryList(vo);
    }

    /**
     * 处理
     * @return
     */
    @RequestMapping("deal")
    public Map<String,Object> dealTask(@RequestBody SourceVo vo){
        return sourceEnterpriseService.dealtask(vo);
    }

    /**
     * 按行政区编码查询
     * @return
     */
    @RequestMapping("queryByCounty")
    public Map<String,Object> queryListByCounty(SourceVo vo){
        return sourceEnterpriseService.queryListByCounty(vo);
    }

    /**
     * 导出
     */
    @RequestMapping("export")
    public ResponseEntity<byte[]> queryExport(SourceVo vo){
        return sourceEnterpriseService.queryExport(vo);
    }
}
